//
//  DDNewsCell.m
//  NetEaseNews
//
//  Created by dqw on 15/7/24.
//  Copyright (c) 2015年 itcast. All rights reserved.
//

#import "DDNewsCell.h"
#import <UIImageView+AFNetworking.h>

@interface DDNewsCell ()

@property (weak, nonatomic) IBOutlet UIImageView *iconView;
@property (weak, nonatomic) IBOutlet UILabel *titleLab;
@property (weak, nonatomic) IBOutlet UILabel *digestLab;
@property (weak, nonatomic) IBOutlet UILabel *replyLab;
@property (strong, nonatomic) IBOutletCollection(UIImageView) NSArray *imgextraView;


@end

@implementation DDNewsCell

- (void)setNews:(DDNews *)news
{
    self.titleLab.text = news.title;
    self.digestLab.text = news.digest;
    
    self.replyLab.text = [NSString stringWithFormat:@"%d回帖", [news.replyCount intValue]];
    [self.iconView setImageWithURL:[NSURL URLWithString:news.imgsrc]];
    
    for (int i = 0; i < news.imgextra.count; i++) {
        UIImageView *imgView = self.imgextraView[i];
        NSDictionary *dic = news.imgextra[i];
        [imgView setImageWithURL:[NSURL URLWithString:dic[@"imgsrc"]]];
    }
}
+ (NSString *)reuseIDWithNews:(DDNews *)news
{
    if (news.imgType && news.imgType.intValue > 0) {
        return @"news3";
    }
    if (news.imgextra && news.imgextra.count > 0) {
        return @"news2";
    }
    return @"news1";
    
}
+ (CGFloat)rowHeightWithNews:(DDNews *)news
{
    
    if (news.imgType && news.imgType.intValue > 0) {
        return 130;
    }
    if (news.imgextra && news.imgextra.count > 0) {
        return 120;
    }
    return 90;
}

@end
